package com.test.leetcode;

/**
 * https://leetcode.cn/problems/fibonacci-number/description/
 * @author sujiafa
 * @date 2025/1/24
 */
public class n509_斐波那契数 {

    public int fib(int n) {
        if (n == 0) {
            return 0;
        }
        if (n == 1) {
            return 1;
        }
        int a = 0;
        int b = 1;
        for (int i = 2; i <= n; i++) {
            int c = a + b;
            a = b;
            b = c;
        }

        return b;
    }
}
